/* 
 *   Date       Developer   Description
 *   
 *
 *   Classname:  com.ytincl.scdp.scdk.db.utils.DropAllTable
 * 
 *   Date:   2009-8-21
 * 
 *   The source code contained in this listing is proprietary to
 *   HLJ POST YITONG INFO-NET CO.,LTD.
 * 
 *   Unauthorized copying, adaptation, distribution, use, or display
 *   is strictly prohibited.
 *   This software is Copyright 2009 HLJ POST YITONG INFO-NET CO.,LTD.
 */
package demo.database.mysql;

import java.sql.Connection;
import java.util.List;

import com.titan.core.utils.db.DBUtils;
import com.titan.core.utils.db.RecordSet;
import com.titan.core.utils.dbinfo.dialect.DBDialect;
import com.titan.core.utils.dbinfo.dialect.IDBDialect;

/**
 *
 *
 * @author 周成功
 *
 */
public class DropAllTable {
    public static void main(String[] args) {
        String url = "jdbc:mysql://127.0.0.1:3306/monitor";
        String userid = "root";
        String password = "123456";
        
        Connection conn = null;
        try {
            IDBDialect dialect = DBDialect.MYSQL.get();
            conn = dialect.getConnection(url, userid, password);
            List<String> tables = dialect.getTables(conn, "monitor");
            for (String table : tables) {
                DBUtils.execute(conn, "drop table " + dialect.identifier(table));
            }
            
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            DBUtils.close(conn);
        }
    }
}

